#include "Graph.h"
namespace Graph_lib
{

const double PI =  3.14159265;
	
	
struct Arc : Shape{
	Arc(Point p, int w, int h, double ds, double de);
	void draw_lines() const;
	Point center() const;
	//Point focus1() const;
	//Point focus2() const;
private:
	double degree_s;
	double degree_e;
	int width;
	int height;
};



struct Box:Shape{
	Box(Point xy, int ww, int hh, int rr = 0) : w(ww), h(hh), r(rr)
    {
        add(xy);
        if (r <= 0 ||  min(h,w)/2-r < 0) r = min(h,w)/5;
		if (h<=0 || w<=0) error("Bad Box: non-positive side");
		if (r < 0) error ("Bad Box: non-positive curvature radius");

    }

    Box(Point x, Point y, int rr = 0) : w(y.x-x.x), h(y.y-x.y)
    {
        add(x);
		if (r <= 0 ||  min(h,w)/2-r < 0) r = min(h,w)/5;
		if (h<=0 || w<=0) error("Bad Box: non-positive width or height");
		if (r < 0) error ("Bad Box: non-positive curvature radius");

    }
    
	void draw_lines() const;
	int height() const { return h; }
    int width()  const { return w; }
	int radius() const { return r; }
protected:
	void draw_empty() const;
	void draw_fill() const;
	Box():w(0), h(0), r(0)
	{}
    int h;    // height
    int w;    // width
	int r;    // radius
};

struct Arrow : Shape {
	Arrow(Point p1, Point p2, int as):arrow_size(as) 
	{
		if (as <= 0) error("Arrow: Bad Aroow, negative arrow size");
		//if (as < int(length()))
			//error("Arrow: Bad Aroow, too big arrow size");
		add(p1);
		add(p2);
	}

	void draw_lines() const;
private:
	double length()
	{
		int lx = (point(1).x-point(0).x);
		int ly = (point(1).y-point(0).y);
		return sqrt(double(lx*lx)+ly*ly); 
	}
	int arrow_size;
};

struct BoxWithText:Box{

	BoxWithText(Point xy, int ww, int hh, int rr, const string& ss);
	void draw_lines() const;
	void set_text(const string& ss)
	{
		tt.set_label(ss);
	}
	void set_font(Font f)
	{
		tt.set_font(f);
	}
	void set_font_size(int fs)
	{
		tt.set_font_size(fs);
	}
	void move(int dx, int dy)
	{
		tt.move(dx, dy);
		Shape::move(dx, dy);
	}
	
private:
	Text tt;
};

}